package net.steam.easyjoboa.biz.impl;

import java.util.List;

import net.steam.easyjoboa.biz.DepartmentBiz;
import net.steam.easyjoboa.dao.DepartmentDao;
import net.steam.easyjoboa.entity.Department;

public class DepartmentBizImpl implements DepartmentBiz {

	private DepartmentDao departmentDao;
	public List<Department> getAllDepartment() {
		String hql = "From Department";
		List<Department> departments = departmentDao.find(hql);
		return departments;
	}
	
	public List<Department> getAllList() {
		return departmentDao.find("from Department");
	}

	public List<Department> getDeparByName(String name){
		return departmentDao.find("from Department where departmentName='"+name+"'");
		
	}
	
	public int addDepartment(Department department) {
		int i = 0;
		try{
			i = (Integer) departmentDao.addEntity(department);
			if (i==0) {
				return 0;
			}
		}catch (Exception a) {
			a.printStackTrace();
		}
		return 1;
	}
	
	public void setDepartmentDao(DepartmentDao departmentDao) {
		this.departmentDao = departmentDao;
	}

}
